package thesis;
import java.util.StringTokenizer;
import java.util.TreeSet;

import com.aliasi.tokenizer.PorterStemmerTokenizerFactory;
import com.aliasi.tokenizer.Tokenizer;


public class WordsTokenizer extends Tokenizer {
	private StringTokenizer st;
	private TreeSet<String> featureWords;
	
	public WordsTokenizer(String s, TreeSet<String> featureWords){
		st = new StringTokenizer(s);
		this.featureWords = featureWords;
	}
	
	public String nextToken() {
		while (st.hasMoreTokens()){
			String token = PorterStemmerTokenizerFactory.stem(st.nextToken());
			if (featureWords.contains(token)){
				return token;
			}
		}
		return null;
	}

}
